/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.services.impl;


import java.sql.SQLException;
import java.util.Date;

import cn.itlaobing.dao.UserDao;
import cn.itlaobing.entity.UserEntity;
import cn.itlaobing.exception.BusinessException;
import cn.itlaobing.services.UserService;

/** 
 * ClassName: UserService <br/> 
 * Function: 用户业务处理<br/> 
 * date: 2017年11月1日 上午11:27:17 <br/> 
 * 
 * @author 王博 
 * @version  
 * @since JDK 1.8 
 */
public class UserServiceimpl implements UserService {
	private UserDao userdao=new UserDao();
	
	/** 
	 * login:(登录). <br/>
	 * 
	 * @author 王博 
	 * @param name
	 * @param pwd
	 * @return
	 * @throws BusinessException 
	 * @since JDK 1.8 
	 */  
	public UserEntity login(String name,String pwd) throws BusinessException {
		UserEntity userentity=null;
		try {
			userentity=userdao.queryNameandPwd(name, pwd);
		} catch (SQLException e) {
			throw new BusinessException(e.getMessage());
		}finally {
			try {
				userdao.close();
			} catch (SQLException e) {
				throw new BusinessException(e.getMessage());
			}
		}
		return userentity;
	}


	/**
	 * updatePlaceOrder:(修改用户上次登录时间). <br/>
	 * 
	 * @author 王博 
	 * @param date
	 * @param id
	 * @return
	 * @throws BusinessException 
	 * @since JDK 1.8 
	 */  
	public int updatePlaceOrder(Date date,int id) throws BusinessException {
		int row=0;
		try {
			row=userdao.updatePlaceOrder(date, id);
		} catch (SQLException e) {
			throw new BusinessException(e.getMessage());
		}finally {
			try {
				userdao.close();
			} catch (SQLException e) {
				throw new BusinessException(e.getMessage());
			}
		}
		return row;
	}
}
